package com.yizhang.pattern.observer.jdk;

import java.util.Observable;
import java.util.Observer;

/**
 * @Author: yi.zhang
 * @CreateTime: 2025-08-25 11:36:43
 * @Description: 老师
 */
public class Teacher implements Observer {

    private String name;

    public Teacher(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void update(Observable o, Object arg) {
        Forum forum = (Forum) o;
        Question question = (Question) arg;
        System.out.println(
                this.name + "老师您好!\n"
                + forum.getName() + "上您有一条新消息：\n"
                + question.getQuestion() + "\n"
                + "提问者：" + question.getStudent()
        );
    }
}
